function getPuzzleArray(num, type) {
	var sqrtNum = Math.sqrt(num)
	if(!sqrtNum){
		console.error('0 puzzle num!')
		return
	}
	//拼图
	var puzzleArray = []
	for(var i=0;i<num;i++){
		var puzzle = {
			backgroundPosition: "",
			index: i,
			leftStart: 0,
			leftEnd: 0,
			topStart: 0,
			topEnd: 0,
			id:`game_${type}_puzzle_${i}`
		}
		puzzleArray.push(puzzle)
	}
	//纵横
	var punzzLines = []
	var punzzRows = []
	for(var i=0;i<sqrtNum;i++){
		punzzLines.push(i)
		punzzRows.push(i)
	}
	//计算块
	var avg = sqrtNum - 1
	punzzLines.forEach((itemLine)=>{
		//行
		yPersent = ((itemLine / avg) * 100).toFixed(2)
		punzzRows.forEach((itemRow)=>{
			//列
			xPersent = ((itemRow / avg) * 100).toFixed(2)
			var index = sqrtNum * itemLine + itemRow
			puzzleArray[index].backgroundPosition = `background-position: ${xPersent}% ${yPersent}%`
		})
	})
	puzzleArray.sort(() => {
		return Math.round(Math.random()) - 0.5;
	})
	return puzzleArray
}
module.exports = {
	getPuzzleArray: getPuzzleArray
}
